package com.wanmait.happyheating.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.happyheating.pojo.HeatingNumber;
import com.wanmait.happyheating.mapper.HeatingNumberMapper;
import com.wanmait.happyheating.service.HeatingNumberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 供暖号码表 服务实现类
 * </p>
 *
 * @author yuQianTao
 * @since 2021-05-13
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class HeatingNumberServiceImpl extends ServiceImpl<HeatingNumberMapper, HeatingNumber> implements HeatingNumberService {
    @Resource
    private HeatingNumberMapper heatingNumberMapper;

    /**
     * 陈宗  2021-05-30
     * 业务逻辑层的供暖号码查询并且分页的方法
     *
     * @param pageNum
     * @param heatingNumber
     * @return
     */
    @Override
    public PageInfo<HeatingNumber> findPage(int pageNum, HeatingNumber heatingNumber) {
        /*//实例化条件封装器
        LambdaQueryWrapper<HeatingNumber> heatingNumberLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //获得模糊查询户主身份证号
        heatingNumberLambdaQueryWrapper.like(HeatingNumber::getHouseholdIdcard, heatingNumber.getHouseholdIdcard());
        //获得模糊查询户主名
        heatingNumberLambdaQueryWrapper.like(HeatingNumber::getHouseholdName, heatingNumber.getHouseholdName());
        //获得模糊查询供暖号码绑定的地址
        heatingNumberLambdaQueryWrapper.like(HeatingNumber::getAddress, heatingNumber.getAddress());*/
        //设置分页的当前页和每页条数
        PageHelper.startPage(pageNum, 2);
        //根据条件封装器的值调用数据访问层的查询所有的方法
        List<HeatingNumber> heatingNumbers = heatingNumberMapper.findSelectList(heatingNumber);
        /*List<HeatingNumber> heatingNumbers=heatingNumberMapper.selectList(heatingNumberLambdaQueryWrapper);*/
        //实例化PageInfo
        PageInfo<HeatingNumber> pageInfo = new PageInfo<>(heatingNumbers, 5);
        return pageInfo;
    }
}
